var ns;

var app = new Vue({
    el: '#app',
    data: {
        ProjectID:0,
        list: [],
        type:1,//1-处理人，2-验收人，3-转交人,3-检查任务转交人
        ID:0,//任务ID
        ChangeUserID:0,
        ChangeUserName:'',

    },
    methods: {
        get_data: function () {
            var that = this;
            var actionValue = "getuserlistbyprojectid";
            var options = {
                action: actionValue,
                ProjectID: that.ProjectID,
            };
            ns.post(options, function (succeed, data, err) {
                    if (succeed) {
                        that.list = data.data;
                    }else{
                        api.toast({
                            msg: err,
                            duration: 2000,
                            location: 'bottom'
                        });

                    }
                    
            },{
                toast: true
            });
        },
        doChoosUser: function (item) {
            var that = this;
            if(that.type==3||that.type==4){
                that.ChangeUserID=item.FinalUserID;
                that.ChangeUserName=item.FinalRealName;
            }
            else{
                api.sendEvent({
                    name: 'do_qualitychoose',
                    extra: {
                        item: item,
                        type:that.type
                    }
                });
                api.closeWin();

            }
            
        },
        to_zhuanjiaoUser:function(){
            var that = this;
            var options = {};
            if(that.type==3){
                options.ID = that.ID;
                options.ChangeUserID = that.ChangeUserID;
                options.ChangeUserName = that.ChangeUserName;
                options.action = "changecheckplan";
            }
            if(that.type==4){
                options.ID = that.ID;
                options.UserID = that.ChangeUserID;
                options.action = "transferoftasks";
            }
            
            ns.post(options, function (succeed, data, err) {
                if (succeed) {
                    api.toast({
                        msg: '转交成功',
                        duration: 2000,
                        location: 'bottom'
                    });
                    api.sendEvent({
                        name: 'reloadservicelist',
                    });
                    api.sendEvent({
                        name: 'close_window',
                    });
                    setTimeout(function () {
                        api.closeWin();
                    }, 500)

                } else if (err) {
                    api.toast({
                        msg: err,
                        duration: 2000,
                        location: 'bottom'
                    });
                }
            }, {
                toast: true
            });

        }

       
      
    }
});
apiready = function () {
    api.parseTapmode();
    ns = window.Foresight.Util;
    app.ID = api.pageParam.id || 0;
    app.ProjectID = api.pageParam.ProjectID || 0;
    app.type = api.pageParam.type;
    app.get_data();
};